import dt from '@dt/dt'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'

let orgs = []

function organization(_this) {
  let opt = {
    key: 'companyIds',
    title: '所属组织',
    tree: {
      options: orgs,
    }
  }
  toolMgr.organization(2).then(res => {
    orgs = res
    opt.tree.options = orgs
  })
  return opt
}

function options(_this, isAudit = false) {
  return [
    organization(_this),
    houseOpt.create({
      to: (info) => {
        return {
          housesIds: info.housesId ? [info.housesId] : null
        }
      }
    }),
    {
      key: 'ruleStatus',
      title: isAudit ? '审核状态' : '状态',
      select: {
        options: dt.dictInfo()[isAudit ? 'RuleStatusEnumTwo' : 'RuleStatusEnum'] 
      }
    }
  ]
}

export default {
  options
}
